<template>
  <div class="community-page">
    <!-- 顶部导航栏 -->
    <header class="community-header">
      <h1>欢迎加入我们的社区</h1>
      <div class="search-bar">
        <input type="text" placeholder="搜索标题或内容..." v-model="searchQuery">
        <button @click="handleTabChange('search')">搜索</button>
      </div>
      <div class="search-btn">
        <nav>
          <button @click="handleTabChange('popular')">热门</button>
          <button @click="handleTabChange('latest')">最新</button>
          <button @click="handleTabChange('my')">我的帖子</button>
        </nav>
      </div>
    </header>

    <!-- 主要内容区 -->
    <div class="community-content">
      <!-- 帖子列表 -->
      <div class="post-list">
        <div v-if="loading" class="loading">加载中...</div>
        <div v-else-if="posts.length === 0" class="empty">暂无帖子</div>
        <div v-else>
          <div v-for="post in posts" :key="post.id" class="post-item" @click="viewPostDetail(post)">
            <div class="post-header">
              <h3 class="post-title">{{ post.title }}</h3>
              <div class="user-info">
                <img :src="post.author.avatar" class="avatar" alt="用户头像">
                <span class="author">{{ post.author.name }}</span>
              </div>
            </div>
            <p class="post-content">{{ post.content }}</p>
            <div class="post-footer">
              <div class="comments">
                <i class="far fa-comment"></i> 评论：{{ post.comments }}
              </div>
              <div class="time">{{ formatTime(post.createdAt) }}</div>
              <span class="tags">
                <span v-for="tag in post.tags" :key="tag" class="tag">{{ tag }}</span>
              </span>
            </div>
          </div>
        </div>
        <div class="custom-pagination">
          <button
            @click="handlePagination(activeTab, 'prev')"
            :disabled="pagination[activeTab].page === 1"
            class="page-btn"
          >上一页</button>

          <span class="page-info">
            第 {{ pagination[activeTab].page }} 页 / 共 {{ Math.ceil(pagination[activeTab].total / pageSizes[activeTab]) }} 页
          </span>

          <button
            @click="handlePagination(activeTab, 'next')"
            :disabled="pagination[activeTab].page >= Math.ceil(pagination[activeTab].total / pageSizes[activeTab]) ||
             pagination[activeTab].total <= pageSizes[activeTab]"
            class="page-btn"
          >下一页</button>
        </div>
      </div>

      <!-- 右侧推荐区 -->
      <div class="recommendations">
       <div class="popular-tags1">
          <h3>创作中心</h3>
          <div class="pictureImg"></div>
          <div class="create-post">
          <button @click="showCreateModal = true">
            <i class="icon-ym icon-ym-extend-pencil" style="margin-right: 6px;"></i>
            创建新帖子
          </button>
        </div>
        </div>
        <div class="popular-tags">
          <h3>热门标签</h3>
          <div v-for="tag in popularTags" :key="tag" class="tag-item">
            <span>#{{ tag }}</span>
          </div>
        </div>
      </div>
    </div>

    <!-- 创建帖子模态框 -->
    <div v-if="showCreateModal" class="modal">
      <div class="modal-content">
        <span class="close" @click="closeModal">&times;</span>
        <h2>创建新帖子</h2>
        <form @submit.prevent="submitPost">
          <div class="form-group">
            <label for="post-title">帖子标题</label>
            <input
              id="post-title"
              v-model.trim="newPost.title"
              required
              maxlength="50"
              placeholder="输入一个吸引人的标题..."
              class="form-input"
            >
          </div>

          <div class="form-group">
            <label for="post-content">内容详情</label>
            <textarea
              id="post-content"
              v-model.trim="newPost.content"
              required
              maxlength="1000"
              placeholder="分享你的知识或想法..."
              class="form-textarea"
            ></textarea>
          </div>

          <div class="form-group">
            <label for="post-tags">添加标签</label>
            <input
              id="post-tags"
              v-model.trim="newPost.tags"
              placeholder="例如: Vue,JavaScript,前端开发"
              @keydown.enter.prevent
              class="form-input"
            >
            <div class="hint">用逗号分隔标签，最多5个</div>
          </div>

          <div class="form-actions">
            <button
              type="button"
              class="cancel-btn"
              @click="closeModal"
            > 取消
            </button>
            <button
              type="submit"
              class="submit-btn"
              :disabled="isSubmitting"
            >
              <span v-if="!isSubmitting">立即发布</span>
              <span v-else>发布中...</span>
            </button>
          </div>
        </form>
      </div>
    </div>
    <!-- 帖子详情弹窗 -->
    <div v-if="showPostDetail" class="modal">
      <div class="modal-content post-detail">
        <span class="close" @click="showPostDetail = false">&times;</span>

        <div class="post-header">
          <h2>{{ currentPost.title }}</h2>
          <div class="user-info">
            <img :src="currentPost.author.avatar" class="avatar" alt="用户头像">
            <span class="author">{{ currentPost.author.name }}</span>
          </div>
        </div>

        <div class="post-content">
          {{ currentPost.content }}
        </div>

        <div class="time">{{ formatTime(currentPost.createdAt) }}</div>

        <div class="comment-section">
          <h3>评论 ({{ comments.length }})</h3>

          <div class="comment-form">
            <textarea v-model="newComment" placeholder="写下你的评论..."></textarea>
            <button @click="submitComment">发表评论</button>
          </div>

          <div v-if="loading" class="loading">加载中...</div>
          <div v-else-if="comments.length === 0" class="empty">暂无评论</div>
          <div v-else class="comment-list">
            <div v-for="comment in comments" :key="comment.id" class="comment-item">
              <div class="comment-header">
                <img :src="comment.author.avatar" class="avatar" alt="用户头像">
                <span class="author">{{ comment.author.name }}</span>
                <span class="time">{{ formatTime(comment.createdAt) }}</span>
              </div>
              <div class="comment-content">{{ comment.content }}</div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import request from '@/utils/request.js'
export default {
  name: 'CommunityPage',
  data() {
    return {
      searchQuery: '',
      loading: false,
      showCreateModal: false,
      newPost: {
        title: '',
        content: '',
        tags: ''
      },
      posts: [],
      popularTags: [],
      showPostDetail: false,
      currentPost: null,
      comments: [],
      newComment: '',
      isSubmitting: false,
      ossConfig: {
        region: 'oss-cn-wuhan-lr',
        accessKeyId: 'LTAI5tE1sjS9v6rVPid3HXzr',
        accessKeySecret: 'd3dCLmg0CBQgMX5fbSjZc6qMPWJcMj',
        bucket: 'mangopdf',
        endpoint: 'https://mangopdf.oss-cn-wuhan-lr.aliyuncs.com'
      },
      pageSizes: {
        Posts: 3,
        popular: 3,
        latest: 3,
        my: 3,
        search: 3,
      },
      pagination: {
        Posts: { page: 1, total: 0 },
        popular: { page: 1, total: 0 },
        latest: { page: 1, total: 0 },
        my: { page: 1, total: 0 },
        search: { page: 1, total: 0 },
      },
      displayLimits: {
        popular: 100,
        latest: 100,
      },
      activeTab: 'Posts',
    }
  },
  computed: {

  },
  mounted() {
    this.searchPosts();
  },
  methods: {
    handlePagination(type, action) {
      const pagination = this.pagination[type];

      if (action === 'prev' && pagination.page > 1) {
        pagination.page--;
      }
      else if (action === 'next' && pagination.page < Math.ceil(pagination.total / this.pageSizes[type])) {
        pagination.page++;
      }

      this.activeTab = type;

      if (type == 'search') {
        this.handleSearch();
      } else {
        this[`search${type}`]();
      }
    },
    handleTabChange(type) {
      this.activeTab = type;
      this.pagination[type].page = 1;
      if (type == 'search') {
        this.handleSearch();
      } else {
        this[`search${type}`]();
      }
    },
    async handleSearch() {
      try {
        this.loading = true;
        const response = await request.post('/api/example/Whu_commuity/getList', {
          page: this.pagination.search.page,
          pageSize: this.pageSizes.search,
          title: this.searchQuery,
          content: this.searchQuery
        });

        if (response.code === 200) {
          this.posts = await this.buildPostsWithUserInfo(response.data.list);
          this.pagination.search.total = response.data.pagination.total;
        } else {
          this.$message.error(response.msg || '搜索失败');
        }
      } catch (error) {
        console.error('搜索失败:', error);
        this.$message.error('搜索失败，请稍后重试');
      } finally {
        this.loading = false;
      }
    },
    async searchpopular() {
      try {
        this.loading = true;

        if (this.pagination.popular.page * this.pageSizes.popular > this.displayLimits.popular) {
          this.posts = [];
          return;
        }

        const remaining = 100 - (this.pagination.popular.page - 1) * this.pageSizes.popular;
        const pageSize = Math.min(this.pageSizes.popular, remaining);

        const response = await request.post('/api/example/Whu_commuity/getList', {
          page: this.pagination.popular.page,
          pageSize: pageSize,
          sidx: 'comments',
          sort: 'desc',
        });
        this.posts = await this.buildPostsWithUserInfo(response.data.list);
        this.pagination.popular.total = Math.min(response.data.pagination.total, this.displayLimits.popular);
      } catch (error) {
        console.error('获取热门帖子失败:', error);
      } finally {
        this.loading = false;
      }
    },

    async searchlatest() {
      try {
        this.loading = true;

        if (this.pagination.latest.page * this.pageSizes.latest > this.displayLimits.latest) {
          this.posts = [];
          return;
        }

        const remaining = 100 - (this.pagination.latest.page - 1) * this.pageSizes.latest;
        const pageSize = Math.min(this.pageSizes.latest, remaining);

        const response = await request.post('/api/example/Whu_commuity/getList', {
          page: this.pagination.latest.page,
          pageSize: pageSize,
          sidx: 'time',
          sort: 'desc'
        });
        this.posts = await this.buildPostsWithUserInfo(response.data.list);
        this.pagination.latest.total = Math.min(response.data.pagination.total, this.displayLimits.latest);
      } catch (error) {
        console.error('获取最新帖子失败:', error);
      } finally {
        this.loading = false;
      }
    },
    async searchmy() {
      try {
        this.loading = true;
        const response = await request.post('/api/example/Whu_commuity/getList', {
          page: this.pagination.my.page,
          pageSize: this.pageSizes.my,
          userid: "1"
        });
        this.posts = await this.buildPostsWithUserInfo(response.data.list);
        this.pagination.my.total = response.data.pagination.total;
      } catch (error) {
        console.error('获取我的帖子失败:', error);
      } finally {
        this.loading = false;
      }
    },
    formatTime(dateString) {
      const date = new Date(dateString);
      return date.toLocaleDateString();
    },
    extractPopularTags() {
      // 收集所有标签
      const allTags = this.posts.flatMap(post => post.tags || []);

      // 统计标签出现频率
      const tagCountMap = allTags.reduce((acc, tag) => {
        acc[tag] = (acc[tag] || 0) + 1;
        return acc;
      }, {});

      // 按出现次数排序并取前5个
      this.popularTags = Object.entries(tagCountMap)
        .sort((a, b) => b[1] - a[1])
        .slice(0, 3)
        .map(item => item[0]);
    },
    closeModal() {
      this.showCreateModal = false;
      this.resetForm();
    },

    resetForm() {
      this.newPost = {
        title: '',
        content: '',
        tags: ''
      };
      this.isSubmitting = false;
    },

    async submitPost() {
      if (this.isSubmitting) return;

      this.isSubmitting = true;

      try {
        // 处理标签
        const tags = this.newPost.tags
          .split(',')
          .map(tag => tag.trim())
          .filter(tag => tag.length > 0)
          .slice(0, 3);

        // 验证表单
        if (!this.newPost.title.trim() || !this.newPost.content.trim()) {
          this.$message.error('标题和内容不能为空');
          return;
        }

        // 构建请求数据
        const postData = {
          title: this.newPost.title,
          content: this.newPost.content,
          tags: tags.join(','),
          time: new Date().toISOString(),
        };

        // 发送创建请求
        const response = await request.post('/api/example/Whu_commuity', postData);

        if (response.code === 200) {
          this.$message.success('帖子创建成功');
          this.closeModal();
          await this.searchPosts();
        } else {
          this.$message.error(response.msg || '创建帖子失败');
        }
      } catch (error) {
        console.error('API请求失败:', error);
        this.$message.error(error.message || '创建帖子失败，请稍后重试');
      } finally {
        this.isSubmitting = false;
      }
    },
    async searchPosts(resetPage = false) {
      try {
        if (resetPage) {
          this.pagination.Posts.page = 1;
        }
        this.activeTab = 'Posts';

        this.loading = true;
        const response = await request.post('/api/example/Whu_commuity/getList', {
          page: this.pagination.Posts.page,
          pageSize: this.pageSizes.Posts,
          title: this.searchQuery,
          content: this.searchQuery
        });

        if (response.code === 200) {
          this.posts = await this.buildPostsWithUserInfo(response.data.list);
          this.pagination.Posts.total = response.data.pagination.total || 0;
          this.extractPopularTags();
        }
      } catch (error) {
        console.error('获取帖子列表失败:', error);
      } finally {
        this.loading = false;
      }
    },
    prevPage() {
      if (this.page > 1) {
        this.page--
        this.searchPosts()
      }
    },

    nextPage() {
      if (this.page < Math.ceil(this.total / this.pageSize)) {
        this.page++
        this.searchPosts()
      }
    },

    async buildPostsWithUserInfo(postList) {
      const postsWithUserInfo = await Promise.all(
        postList.map(async post => {
          try {
            const userInfo = await this.getUserInfo(post.userid);

            return {
              id: post.id,
              title: post.title,
              content: post.content,
              tags: post.tags ? post.tags.split(',') : [],
              createdAt: post.time ,
              comments: post.comments || 0,
              author: {
                userid: post.userid,
                name: (userInfo && userInfo.realName) || '匿名用户',
                avatar: (userInfo && userInfo.avatar) ? this.formatAvatarUrl(userInfo.avatar) : ''
              }
            };
          } catch (error) {
            console.error(`处理帖子 ${post.id} 失败:`, error);
            return {
              ...post,
              tags: post.tags ? post.tags.split(',') : [],
              createdAt: post.time || new Date().toISOString(),
              comments: post.comments || 0,
              author: {
                userid: post.userid,
                name: '加载失败',
                avatar: ''
              }
            };
          }
        })
      );
      return postsWithUserInfo;
    },

    async getUserInfo(userId) {
      try {
        if (!userId) {
          console.warn('用户ID为空');
          return null;
        }

        const response = await request.get('/api/permission/Users/Current/GetUserInfoById', {
          params: {
            userId,
          }
        });

        if (response.code === 200) {
          return response.data;
        }
        throw new Error(response.msg || '获取用户信息失败');
      } catch (error) {
        console.error(`获取用户 ${userId} 信息失败:`, error);
        return null;
      }
    },
    formatAvatarUrl(avatar) {
      if (!avatar) return '';

      // 如果已经是完整URL则直接返回
      if (avatar.startsWith('http')) {
        return avatar;
      }

      // 处理后端返回的API路径格式
      if (avatar.startsWith('/api/file/Image/userAvatar/')) {
        const filename = avatar.split('/').pop();
        return `${this.ossConfig.endpoint}/avatars/${filename}`;
      }

      // 默认处理其他情况
      return avatar.startsWith('avatars/')
        ? `${this.ossConfig.endpoint}/${avatar}`
        : `${this.ossConfig.endpoint}/avatars/${avatar}`;
    },
    async viewPostDetail(post) {
      this.currentPost = post
      this.showPostDetail = true
      await this.fetchComments();
    },
    async fetchComments() {
      try {
        this.loading = true;
        const response = await request.post('/api/example/Whu_commuitycomments/getList', {
          postid: this.currentPost.id,
          page: 1,
          pageSize: 50
        });

        if (response.code === 200) {
          this.comments = await this.buildCommentsWithUserInfo(response.data.list);
        }
      } catch (error) {
        console.error('获取评论失败:', error);
        this.comments = [];
      } finally {
        this.loading = false;
      }
    },
    async buildCommentsWithUserInfo(commentList) {
      const commentsWithUserInfo = await Promise.all(
        commentList.map(async comment => {
          try {
            const userInfo = await this.getUserInfo(comment.userid);

            return {
              id: comment.id,
              content: comment.content,
              createdAt: comment.time,
              author: {
                userid: comment.userid,
                name: (userInfo && userInfo.realName) || '匿名用户',
                avatar: (userInfo && userInfo.avatar) ? this.formatAvatarUrl(userInfo.avatar) : ''
              }
            };
          } catch (error) {
            console.error(`处理评论 ${comment.id} 失败:`, error);
          }
        })
      );
      return commentsWithUserInfo;
    },
    async submitComment() {
      if (!this.newComment.trim()) {
        this.$message.warning('评论内容不能为空');
        return;
      }

      try {
        const response = await request.post('/api/example/Whu_commuitycomments', {
          postid: this.currentPost.id,
          content: this.newComment,
          time: new Date().toISOString()
        });

        if (response.code === 200) {
          this.$message.success('评论发表成功');
          this.newComment = '';
          await this.fetchComments();
          await this.searchPosts();
        } else {
          this.$message.error(response.msg || '评论发表失败');
        }
      } catch (error) {
        console.error('发表评论失败:', error);
        this.$message.error('发表评论失败，请稍后重试');
      }
    },
  },
}
</script>

<style scoped>
.community-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  position: relative;
}

.community-header {
  text-align: center;
  margin-bottom: 30px;
}

.search-bar {
  margin-top: 15px;
}

.search-bar input {
  padding: 8px 15px;
  width: 44%;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.search-bar button {
  padding: 8px 20px;
  margin-left: 10px;
  background-color: #f6ca46;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.search-btn {
  position: relative;
  margin-top: 50px;
  margin-bottom: -20px;
  text-align: left;
  left:90px;
}

.search-btn button {
  padding: 10px 25px;
  margin: 0 8px;
  background-color: white;
  color: var(--accent-yellow);
  border: none;
  border-radius: 30px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.community-content {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  position: relative;
  left: 100px;
}

.community-header > nav {
  display: flex;
  gap: 10px;
  justify-content: left;
  margin-top: 16px;
}

.community-header > nav button {
  padding: 10px 24px;
  background-color: #f6ca46;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.community-header > nav button:hover {
  background-color: #f5edc6;
}

.post-list {
  flex: 0 0 750px;
}

.post-item {
  background-color: white;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.post-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.post-title {
  margin: 0;
  font-size: 1.2em;
  flex: 1;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
}

.author {
  font-weight: bold;
}

.time {
  color: #666;
  font-size: 0.8em;
}

.post-content {
  margin: 10px 0;
  color: #333;
}

.post-footer {
  display: flex;
  align-items: center;
  margin-top: 15px;
  color: #666;
}

.comments {
  margin-right: 15px;
  cursor: pointer;
}


.tags {
  margin-left: auto;
}

.tag {
  display: inline-block;
  background-color: #f0f0f0;
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 5px;
  font-size: 0.8em;
}

.recommendations {
  flex: 0 0 250px;
}

.recommend-users, .popular-tags {
  background-color: white;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.recommend-users, .popular-tags1 {
  background-color: white;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.recommend-users h3, .popular-tags h3 {
  margin-top: 0;
  margin-bottom: 15px;
  font-size: 1.1em;
}

.create-post button {
  margin-top: 10px;
  padding: 10px 30px;
  background-color: #ffffff;
  color: #e0972a;
  border: 1px solid #e0972a;
  border-radius: 4px;
  margin-left: 10%;
  cursor: pointer;
  font-size: 1em;
  margin-bottom: 10px;
  transition: background-color 0.3s, color 0.3s;
}

.create-post button:hover {
  background-color: #f5edc6;
  color: #fffdfd;
}

.tag-item {
  display: inline-block;
  margin-right: 8px;
  margin-bottom: 8px;
  background-color: #f0f0f0;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
}

.tag-item:hover {
  background-color: #e0e0e0;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  width: 600px;
  padding:30px;
  border-radius: 12px;
  box-shadow: 0 5px 20px rgba(0,0,0,0.1);

  background: linear-gradient(to bottom right, #fffce6, #ffffff);
  border: 1px solid #e0e0e0;
}


.modal-content h2 {
  text-align: center;
  margin-bottom: 25px;
  color: #2c3e50;
  font-weight: 600;
  position: relative;
  padding-bottom: 10px;
}

.modal-content h2::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 25%;
  width: 50%;
  height: 2px;
  background: linear-gradient(to right, #f6ca46, #2c3e50);
}


.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: #555;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid #ddd;
  border-radius: 6px;
  transition: all 0.3s;
  font-size: 14px;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: #f6ca46;
  box-shadow: 0 0 0 3px rgba(66, 185, 131, 0.1);
  outline: none;
}

.form-group textarea {
  min-height: 120px;
  resize: vertical;
}

.form-actions {
  margin-top: 30px;
}

.submit-btn {
  padding: 8px 20px;
  margin-left: 10px;
  background-color: #f6ca46;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(183, 185, 66, 0.3);
}

.cancel-btn {
  padding: 8px 20px;
  margin-left: 10px;
  background-color: #838383;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.cancel-btn:hover {
  background-color: #f1f1f1;
  transform: translateY(-2px);
}


.hint {
  color: #888;
  font-size: 12px;
  margin-top: 5px;
  font-style: italic;
}


.close {
  color: #666;
  transition: all 0.3s;
  font-size: 24px;
  top: 15px;
  right: 15px;
}

.close:hover {
  color: #f6ca46;
  transform: rotate(90deg);
}

.loading, .empty {
  text-align: center;
  padding: 30px;
  color: #666;
}

.post-detail {
  max-width: 800px;
  max-height: 80vh;
  overflow-y: auto;
}

.post-detail .post-header {
  margin-bottom: 20px;
}

.post-detail .post-content {
  margin: 20px 0;
  padding: 15px;
  background: #f9f9f9;
  border-radius:- 4px;
}

.comment-section {
  margin-top: 30px;
  border-top: 1px solid #eee;
  padding-top: 20px;
}

.comment-form {
  margin: 15px 0;
}

.comment-form textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  min-height:80px;
  margin-bottom:10px;
}

.comment-form button {
  background-color: #f6ca46;
  color: white;
  border: none;
  padding: 8px 15px;
  border-radius:4px;
  cursor:pointer;
}

.comment-item {
  padding: 15px 0;
  border-bottom:1px solid #f0f0f0;
}

.comment-header {
  display:flex;
  align-items:center;
  margin-bottom:8px;
}

.comment-header .avatar {
  width:30px;
  height:30px;
  border-radius:50%;
  margin-right:10px;
}

.comment-header .author {
  font-weight:bold;
  margin-right:10px;
}

.comment-header .time {
  color:#666;
  font-size:0.8em;
}

.comment-content {
  padding-left:40px;
  color:#333;
}


.modal-enter-active, .modal-leave-active {
  transition: opacity 0.3s;
}
.modal-enter, .modal-leave-to {
  opacity: 0;
}

.modal-content {
  animation: modalIn 0.4s ease-out;
}

.custom-pagination {
  margin-top: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
}

.page-btn {
  padding: 8px 16px;
  background-color: #f6ca46;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.page-btn:hover:not(:disabled) {
  background-color: #f5edc6;
}

.page-btn:disabled {
  background-color: #cccccc;
  cursor: not-allowed;
}

.page-info {
  color: #666;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}


.submit-btn:disabled {
  position: relative;
}

.submit-btn:disabled::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.pictureImg{
  margin-top: 30px;
  height:160px;
  width: 70%;
  margin-left: 15%;
  margin-bottom: 20px;
  background-image: url(../../../assets//images/interview_bg2.png);
   background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
</style>
